package com.woniu.adapter;

import com.woniu.outlet.mysql.dao.CouponDao;
import com.woniu.outlet.mysql.po.Coupon;
import com.woniu.service.domain.CouponDto;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class CouponAdapter {

    @Autowired
    private CouponDao couponDao;

    public void add(CouponDto couponDto) {
        Coupon coupon = new Coupon();
        BeanUtils.copyProperties(couponDto, coupon);
        couponDao.insert(coupon);
    }

    public Coupon getById(Integer id) {
        Coupon coupon = couponDao.selectByPrimaryKey(id);
        return coupon;
    }
}
